﻿
@model YodaMaster.Models.TimeTable
@using System.Data;

@{
    ViewBag.Title = "MySchedule";
}

<h2>My Schedule</h2>




<p>
</p>
<p></p>

        @Html.ActionLink("Remove", "RemoveMySchedule")
 


@Html.ActionLink("View Tests","View_Tests", "ScheduleController", null)

<p>
</p>
<p></p>

<table border="1"> 
    <thead> 
    <tr> 
    @foreach (System.Data.DataColumn col in Model.timetable.Columns)     
    {          
        <th>@col.ColumnName</th> 
    }     
    </tr> 
    </thead>         
    <tbody> 

       

           @foreach (System.Data.DataRow row in Model.timetable.Rows)     
          {
            foreach (DataColumn col in Model.timetable.Columns)
           {
               int i = Model.timetable.Rows.IndexOf(row);
               if (i > 0 && Model.timetable.Rows[i - 1][col].ToString().Contains(row[col.ColumnName].ToString()) == true && row[col.ColumnName].ToString() != "" && Model.timetable.Rows[i - 1][col].ToString().Contains("@") == false)
               {
                   row[col.ColumnName] = row[col.ColumnName] + "%$";
               }
           }
        }
          
    
      


    @foreach (System.Data.DataRow row in Model.timetable.Rows)     
    {
        
        
        <tr> 
        @foreach (DataColumn col in Model.timetable.Columns)         
        {
            
            if(row[col.ColumnName].ToString().Contains("%$"))
            {
                row[col.ColumnName] = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\"";    
            }
            if(row[col.ColumnName].ToString().Contains("@"))
            {
                <td style =" background-color: #FF0000"> @Html.Raw(row[col.ColumnName].ToString().Replace(Environment.NewLine, "<br />"))   </td>
            }
           else if(row[col.ColumnName].ToString().IsEmpty() || col.ColumnName == "Hour/Day")
           {
                 <td> @Html.Raw(row[col.ColumnName].ToString().Replace(Environment.NewLine, "<br />"))   </td> 
           } 
           else
           {
               <td style =" background-color:#00FF00"> @Html.Raw(row[col.ColumnName].ToString().Replace(Environment.NewLine, "<br />"))   </td> 
           }  
            
        }         
        </tr> 
    }     
    </tbody> 
</table>


